package cate.common.table.activity.mtower;

import cate.common.table.ERow;
import cate.common.table.XSSFRowWrap;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MTowerLevelRow extends ERow {

    @NoteField(value = "开服天数")
    public int day;

    @NoteField(value = "怪物实例")
    public String dynInsCode;

    @NoteField(value = "首通奖励")
    public String firstRewardStr;

    @NoteField(value = "扫荡奖励")
    public String mopRewardStr;

    @NoteField(value = "扫荡消耗")
    public String mopCostStr;

    @NoteField(value = "星级挑战ID")
    public String starChallengeStr;

    @NoteField(value = "活动配置ID")
    public int configId;


    @Override
    public void parse(XSSFRowWrap xrw) {
        super.parse(xrw);
        this.id = xrw.getInteger("配置ID",0);
        this.day = xrw.getInteger("开服天数",0);
        this.dynInsCode = xrw.getString("怪物实例");
        this.firstRewardStr = xrw.getString("首通奖励");
        this.mopRewardStr = xrw.getString("扫荡奖励");
        this.mopCostStr = xrw.getString("扫荡消耗");
        this.starChallengeStr = xrw.getString("星级挑战ID");
        this.configId = xrw.getInteger("活动配置ID",0);
    }

    public List<Integer> challengeIds;

    public Map<Integer, String> mopCosts;

    @Override
    public void decode() {
        challengeIds = new ArrayList<>();
        if (StringUtils.isNotBlank(starChallengeStr)) {
            String[] split = starChallengeStr.split("#");
            for (String str : split) {
                challengeIds.add(Integer.parseInt(str));
            }
        }
        mopCosts = new HashMap<>();
        if (StringUtils.isNotBlank(mopCostStr)) {
            String[] split = mopCostStr.split("#");
            for (String str : split) {
                String[] splitMops = str.split(":");
                String cost = splitMops[1]+":"+splitMops[2]+":"+splitMops[3];
                mopCosts.put(Integer.parseInt(splitMops[0]),cost);
            }
        }
    }
}
